<script setup>
import { onMounted, ref, computed } from "vue";
const $props = defineProps(["list", "typeId"]);

onMounted(() => {});

const handleClick = (url) => {
  window.open(url);
};

const navList = computed(() => {
  return $props.list.filter((item) => item.typeId === $props.typeId);
});
</script>

<template>
  <div class="group" v-if="navList.length > 0">
    <div class="header">常用推荐</div>
    <div class="websites">
      <div
        class="website"
        v-for="item in navList"
        :key="item.id"
        @click="handleClick(item.ip_address)"
      >
        <div class="website-top">
          <img :src="item.logo" alt="" />
          <span>{{ item.title }}</span>
        </div>
        <div class="website-bottom">{{ item.description }}</div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.group {
  width: 100%;
  margin-bottom: 20px;
  transition: all 0.35s ease;
  border-radius: 5px;
  &:hover {
    border-radius: 5px;
    box-shadow: 1px 1px 5px 5px rgba(49, 211, 162, 0.322);
  }
  .header {
    background-color: #94ce6f61;
    line-height: 40px;
    height: 40px;
    color: #000;
    font-weight: 700;
    text-align: center;
    border-top-right-radius: 5px;
    border-top-left-radius: 5px;
  }
  .websites {
    padding: 0 10px;
    background-color: #fff;
    padding-top: 10px;
    display: flex;
    flex-wrap: wrap;
    font-size: 15px;
    .website {
      max-width: 220px;
      min-width: 150px;
      flex: 1;
      margin-bottom: 10px;
      padding: 10px;
      cursor: pointer;
      &:hover {
        background: #3a8ee62e;
        border-radius: 10px;
      }
      .website-top {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
        span {
          margin-left: 10px;
          font-weight: 700;
        }
        img {
          width: 40px;
          height: 40px;
        }
      }
      .website-bottom {
        color: #c3c3c3;
        width: 90%;
        word-break: break-all;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }
    }
  }
}
</style>
